:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99,102,241,0.1);
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --surface: #fff;
    --text: var(--gray-800);
    --text-light: var(--gray-500);
    --radius: 0.375rem;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --success-rgb: 34,197,94;
    --warning-rgb: 234,179,8;
    --danger-rgb: 239,68,68;
}

/* Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', -apple-system, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--gray-50);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

button {
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    outline: none;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0;
    width: 100%;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-800);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.25rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-secondary {
    background: #B92B3D;
    border-color: #B92B3D;
    color: white;
}

.btn-secondary:hover {
    background: #9e2434;
    border-color: #9e2434;
}

.btn-sm {
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.button-group .btn {
    flex: 1;
}

/* Split panel layout */
.split-panel {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

#file-split-panel {
    display: flex;
    flex-direction: row;
}

/* File explorer panel */
#file-explorer {
    flex: 0 0 260px;
    height: 100%;
    overflow: auto;
    background: var(--surface);
    border-right: 1px solid var(--gray-200);
    padding: 0;
    position: relative;
    min-width: 200px;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* to not show horizontal scrollbar with resizer */
}

#file-explorer-resizer {
    position: absolute;
    top: 0;
    right: -5px;
    width: 10px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.05), transparent);
}

#file-explorer-resizer:hover {
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.1), transparent);
}

.file-explorer-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.file-search {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
}

.file-search input {
    flex: 1;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 0.5rem;
    font-size: 0.875rem;
    outline: none;
}

.file-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary-light);
}

#file-search-clear {
    margin-left: 0.5rem;
    color: var(--gray-500);
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem;
    border-radius: var(--radius);
}

#file-search-clear:hover {
    background: var(--gray-100);
}

.search-highlight {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.search-no-results {
    padding: 1rem;
    font-style: italic;
    color: var(--gray-500);
    text-align: center;
}

.file-explorer-content {
    overflow: auto;
    flex: 1;
    padding: 1rem;
}

.file-explorer-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Main view panel */
#main-view-panel {
    flex: 1;
    height: 100%;
    overflow: auto;
    padding: 1.5rem;
    background: var(--gray-50);
}

/* Stats cards */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.stat-title {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
}

/* Progress bar */
.progress-container {
    width: 100%;
    height: 0.5rem;
    background: var(--gray-200);
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s;
}

/* File tree */
.file-tree {
    list-style: none;
    padding-left: 0;
    margin: 0;
    font-size: 0.875rem;
}

.file-tree li {
    margin: 0.25rem 0;
}

.file-tree ul {
    list-style: none;
    padding-left: 1.25rem;
    margin: 0.25rem 0;
}

.file-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius);
    transition: background-color 0.2s;
}

.file-item:hover {
    background: var(--gray-100);
}

.file-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.file-toggle {
    width: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    color: var(--gray-500);
}

.file-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-coverage {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    margin-left: 0.5rem;
}

/* File tree icons */
.directory > .file-item > .file-icon:before { content: "📁"; }
.directory.expanded > .file-item > .file-icon:before { content: "📂"; }
.file > .file-item > .file-icon:before { content: "📄"; }
.directory > .file-item > .file-toggle:before { content: "▶"; }
.directory.expanded > .file-item > .file-toggle:before { content: "▼"; }
.file > .file-item > .file-toggle { visibility: hidden; }
.directory > ul { display: none; }
.directory.expanded > ul { display: block; }

/* Source files */
.source-file {
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: var(--surface);
}

.source-file-header {
    padding: 0.75rem 1rem;
    background: #12181E;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s;
}

.source-file-header:hover {
    background: #1e2832;
}

.source-file-header .file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.source-file-header .file-name {
    font-weight: 500;
}

.source-file-header .coverage-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.source-file-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.source-file.expanded .source-file-content {
    max-height: none;
}

.source-file-stats {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Code styling */
.code-container {
    position: relative;
    overflow: auto;
    max-height: 600px;
}

.code-coverage-table {
    border-collapse: collapse;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    tab-size: 4;
    width: 100%;
}

.code-coverage-table pre {
    margin: 0;
    font-family: inherit;
}

.row-line-number {
    user-select: none;
    text-align: right;
    padding: 0 0.75rem;
    width: 1%;
    min-width: 2.5rem;
    color: var(--gray-400);
    background: var(--gray-100);
    border-right: 1px solid var(--gray-200);
}

.row-reverted-status {
    user-select: none;
    text-align: center;
    width: 1%;
    min-width: 2.25rem;
    max-width: fit-content;
    padding: 0 0.25rem;
    color: var(--gray-600);
    background: var(--gray-100);
    border-right: 1px solid var(--gray-200);
    white-space: nowrap;
}

.row-source {
    padding: 0 0.75rem;
}

.row-line-covered {
    background: rgba(var(--success-rgb), 0.1);
}

.row-line-uncovered {
    background: rgba(var(--danger-rgb), 0.1);
}

/* Footer */
footer {
    background: var(--surface);
    border-top: 1px solid var(--gray-200);
    padding: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Responsive */
@media (max-width: 768px) {
    .stats-container { grid-template-columns: 1fr; }
    #file-explorer { display: none; }
}